﻿/*
 *  Source code courtesy of the desktopWeb.CodePlex.com community project. See MS-PL license on Codeplex.com. 
 *  This is beta code not intended for a production application.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyData.ExpressionBuilder.Interfaces;
using System.ComponentModel;
using System.Collections.ObjectModel;
using MyData.ExpressionBuilder.Model;

namespace MyData.ExpressionBuilder.BaseExtensions
{
  //IExpressionExtension
  public abstract class ExpressionBuilderItemsProviderBase : IExpressionExtension, IExpressionItemsProvider
  {
    protected abstract List<ListItem> RunExtension(IEnumerable<ListItem> metadata);

    //Next: Async Provider Items since data could come from any source including SharePoint in the cloud
    //  ActivityAction?
    public Action OnDataAvailable { get; set; }
    public IEnumerable<ListItem> MetaData { get; set; }

    protected ExpressionBuilderItemsProviderBase() { }
    
    public List<ListItem> Items
    {
      get {
        //Next: Async OnDataAvailable();
        return this.RunExtension(this.MetaData);      
      }      
    }
  }
}
